import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import './request.dart';
import '../general.dart';
import '../model/login_info.dart';
import './loading.dart';
import '../../utils/general.dart';
class LoginRequest {
  void loginWith({@required BuildContext context, @required String email, @required String sms, @required String pass}) async {
    Loading.show(context);
    Map<String, dynamic> map = await Request().get('/submit', queraParameters:{'email':email,'sms':sms,'password':pass});
    if (map['failure'] == null) {
      Loading.dismissLoading();
      LoginInfo info = LoginInfo.fromJSON(map['success']);
      FFChangeNotifier noti = Provider.of<FFChangeNotifier>(context, listen: false);
      noti.updateLoginInfo = info;
    }else {
      Loading.dismissLoading();
      showMessage(context, map['failure']['message'] ?? '请求失败');
    }
  }
}